import sys
import time
import itertools
import calcutils
import multiprocessing

def sum3d(a):
    result = 0
    for x in range(100):
        for y in range(100):
            for z in range(100):
                result += a[x][y][z]
    return result

def main(argv):
    a = [[[calcutils.calc(x, y, z) for x in range(100)] for y in range(100)] for z in range(100)]
    #print(a)

    p = multiprocessing.Pool(4)

    n = int(1e8)
    r = range(0, 100**3 + 1, n)

    t0 = time.time()
    #print(sum3d(a))
    print(p.map(sum3d, [a for x in r]))
    t1 = time.time()
    print("sum3d took", t1 - t0);

if __name__ == "__main__":
    main(sys.argv)
